package com.joysuch.wwyt.workflow.enums;

/**
 * @Author ZhaoQiuWei
 * @Date 2021/5/17 9:29
 */
public enum WorkFlowCodeTimeStampEnum {
    YMD(0, "yyyyMMdd"),
    YM(1, "yyyyMM"),
    Y(2, "yyyy");

    private Integer index;
    private String value;

    private WorkFlowCodeTimeStampEnum(Integer index, String value) {
        this.index = index;
        this.value = value;
    }

    private Integer getIndex() {
        return index;
    }

    private String getValue() {
        return value;
    }

    private boolean is(Integer index) {
        return this.index.equals(index);
    }

    public static WorkFlowCodeTimeStampEnum findByIndex(Integer index) {
        if (index == null) {
            return null;
        }
        for (WorkFlowCodeTimeStampEnum timeStampEnum : WorkFlowCodeTimeStampEnum.values()) {
            if (timeStampEnum.index.equals(index)) {
                return timeStampEnum;
            }
        }
        return null;
    }

    public static String findValueByIndex(Integer index) {
        WorkFlowCodeTimeStampEnum timeStampEnum = findByIndex(index);
        return timeStampEnum == null ? null : timeStampEnum.getValue();
    }
}
